package com.game.data.vo
{
	import base.BaseHero;
	import base.BaseVO;
	
	import com.dusk.util.RandomUtil;
	import com.dusk.util.ResUtil;
	
	import config.Config;
	
	public class HeroGroupVO extends BaseVO
	{
		public function HeroGroupVO()
		{
			super();
		}
		
		public var hero:BaseHero;
		
		public var player:PlayerDataVO;
		
		public function createHero(userData:PlayerDataVO):BaseHero
		{
			var hero:BaseHero;
			hero = ResUtil.getNewObj("export.hero.Role" + userData.roleId) as BaseHero;
			hero.setPlayer(userData);
			hero.x = 170;
			hero.y = 350;
			hero.start();
			return hero;
		}
		
		public function getHero():BaseHero
		{
			return hero;
		}
		
		public function getHeroArray():Array
		{
			var arr:Array = [];
			if (Boolean(hero) && !hero.isDead())
			{
				arr.push(hero);
			}
			return arr;
		}
		
		public function getPetArray():Array
		{
			var arr:Array = [];
			if (Boolean(hero) && !hero.isDead())
			{
				if (hero.getPet())
				{
					arr.push(hero.getPet());
				}
			}
			return arr;
		}
		
		
		public function getHeroAndPetArray():Array
		{
			var arr:Array = [];
			if (hero && !hero.isDead())
			{
				arr.push(hero);
				if (hero.getPet())
				{
					arr.push(hero.getPet());
				}
			}
			return arr;
		}
		
		public function getRandomHero():BaseHero
		{
			return RandomUtil.randSwitch(getHeroArray()) as BaseHero;
		}
		
		public function destroy():void
		{
			if(hero)
			{
				if (hero.getPlayer())
				{
					hero.getPlayer().reSetAllPetState();
				}
				hero.roleProperties.destroy();
				hero.roleProperties = null;
				hero.destroy();
				hero = null;
			}
			Config.getIns().team = null;
		}
	}
}
